package com.ywy.common.rest;

import lombok.Data;

import java.io.Serializable;

/**
 * 数据对象返回实体
 * @author ywy
 *
 */
@Data
public class Result implements Serializable {
	/**
	 * 状态码
	 */
	private Integer status;

	/**
	 * 详细信息
	 */
	private String msg;

	/**
	 * 数据
	 */
	private Object data;

	public Result() {

	}

	public Result(Integer status, String msg, Object data) {
		this.status = status;
		this.msg = msg;
		this.data = data;
	}

	public static Result success() {
		return new Result(0, "操作成功", null);
	}

	public static Result success(Object data) {
		return new Result(0, "操作成功", data);
	}

	public static Result success(String message, Object data) {
		return new Result(0, message, data);
	}

	public static Result failure() {
		return new Result(-1, "操作失败", null);
	}

	public static Result failure(Integer status, String message) {
		return new Result(status, message, null);
	}

	public static Result failure(String message) {
		return new Result(1, message, null);
	}
}
